#include <stdio.h>
int table2[] = {12, 76, 29, 15, 62, 35, 33, 89, 48, 20};// 查找表2
int size2 = sizeof(table2) / sizeof(table2[0]);
int cnt;//记录查找次数
int sequentialSearch(int key) {// 查找key=35的顺序查找算法
	for (int i = 0; i < size2; i++) {
		if (table2[i] == key) {
			return i; // 返回找到的索引
		}
		cnt++;
	}
	return -1; // 如果没有找到，返回-1
}
int main() {
	int key = 35;
	int index = sequentialSearch(key);
	printf("查找key=%d的顺序查找算法：\n", key);
	if (index != -1) {
		printf("找到，索引：%d,比较次数：%d\n", index,cnt);
	} else {
		printf("未找到\n");
	}
	return 0;
}

